<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
	</head>
	<body>
		<table>
			<tr>
				<td><input type="button" name="" id="" value="加" onclick="num('+','=')" /></td>
				<td><input type="button" name="" id="" value="减" onclick="num('-','=')"/></td>
				<td><input type="button" name="" id="" value="乘" onclick="num('*','=')"/></td>
				<td><input type="button" name="" id="" value="除" onclick="num('/','=')"/></td>
			</tr>
		</table>
		<table id="cale">
			<tr>
				<td><input type="text" style="width: 100px;" name="x" id="x" value="" /></td>
				<td><label id="op" name="op"></label></td>
				<td><input type="text" style="width: 100px;" name="y" id="y" value="" /></td>
				<td><input type="button" name="Equal" id="Equal" value="" onclick="arithmetic()" /></td>
				<td><label id="z"></label></td>
			</tr>
			
		</table>
	</body>
	<script type="text/javascript">
		function num(op,Equal){
			var aa=document.getElementById("cale")

			document.getElementById("x").value ="";
			document.getElementById("y").value ="";
			document.getElementById("z").value ="";
			document.getElementById("op").value =op;
			document.getElementById("Equal").value =Equal;

		}
		function arithmetic(){
			var x = parseInt(document.getElementById("x").value);
			var y = parseInt(document.getElementById("y").value);
			var op = document.getElementById("op").value;
			var z="";
			switch(op){
				case '+':
				z=x+y;
				break;
				case '-':
				z=x-y;
				break;
				case '*':
				z=x*y;
				break;
				case '/':
				z=x/y;
				break;
				default:
				z="";
			}
			console.log(x, op, y, '=', z);
			document.getElementById("z").innerText=z;
		}
	</script>
</html>
